﻿function change_text(p_obj,p_value){
	p_obj.value = p_value;
}
function show_preview_modal_dialog_onclick(p_goto_url,p_fuseaction)
{
	document.all.txt_meaning.value=idContent.document.body.innerHTML;
	var a = new Array();
	a[0]  = document.all.txt_term.value;
	a[1]  = document.all.txt_meaning.value;
	v_url = "/isa-dic-php/dsp_preview_modal_dialog.php";
	v_url = v_url + "?goto_url=" + p_goto_url + "&hdn_item_id=0" + "&fuseaction=" + p_fuseaction + "&modal_dialog_mode=1" + "&" + randomizeNumber();
	sRtn = window.showModalDialog(v_url,a,"dialogWidth:520pt;dialogHeight:470pt;dialogTop:60pt;status:no;resizable:yes;scroll:yes;");
	if (!sRtn) return;
}
function filter_onclick(p_fuseaction){
	f = document.forms(0);
	//alert(p_fuseaction);return;
	f.hdn_back_agency_id.value = f.cbo_af_agency.value;
	f.hdn_back_cate_id.value = f.cbo_af_cate.value;
	f.hdn_status.value = f.cbo_status.value;
	if (f.rad_filter[0].checked){
		f.hdn_method.value = 1;
	}else{
		f.hdn_method.value = 0;
	}
	f.hdn_filter.value = f.txt_filter_value.value;
	f.fuseaction.value = p_fuseaction;
	f.submit();
}
function save_info(p_fuseaction){
	if (verify(document.forms(0))){
		document.forms(0).fuseaction.value = p_fuseaction;
	} else {
		return;
	}
	document.forms(0).hdn_fisrt.value = eval(document.forms(0).hdn_fisrt.value) + 1;
	btn_save_onclick(p_fuseaction);
}

function btn_add_af_onclick(p_obj, p_fuseaction, p_goto_url){
	p_obj.value = "";
	if (_MODAL_DIALOG_MODE==1){
		v_url = _DSP_MODAL_DIALOG_URL_PATH;
		v_url = v_url + "?goto_url=" + p_goto_url + "&hdn_item_id=0" + "&fuseaction=" + p_fuseaction + "&modal_dialog_mode=1" + "&" + randomizeNumber();
		sRtn = showModalDialog(v_url,"","dialogWidth=470pt;dialogHeight=210pt;status=no;scroll=no;");
		//alert(sRtn);
		document.forms(0).fuseaction.value = "";
		document.forms(0).submit();
	}else{
		document.forms(0).fuseaction.value = p_fuseaction;
		document.forms(0).submit();
	}	
}
function btn_approve_af_onclick(p_fuseaction, p_goto_url){
	f = document.forms(0);
	if (!checkbox_value_to_list(f.chk_af_id,",")){
		alert("Chưa có đối tượng nào được chọn");
	}	
	else{
		try{
			if (!f.chk_af_id.length)
			{
				if (f.chk_af_id.checked)
				{
					v_af_id = f.chk_af_id.value;
				}
			}
			else
			{	
				for(i=0;i<f.chk_af_id.length;i++)
				{
					if (f.chk_af_id[i].checked)
					{
						v_af_id = f.chk_af_id[i].value;
					}
				}
			}	
		}catch(e){;} 
		f.hdn_af_id.value = v_af_id;
		f.fuseaction.value = p_fuseaction;
		f.submit();
	}
}
function select_af_concern(){
	f = document.forms(0);
	v_url = _DSP_MODAL_DIALOG_URL_PATH;
	v_url = v_url + "?goto_url=" + escape("af/index.php?hdn_af_id="+f.hdn_af_id.value);
	v_url = v_url + "&hdn_item_id=0" + "&fuseaction=DISPLAY_ALL_AF_FOR_ADDING" + "&modal_dialog_mode=1" 
	sRtn = showModalDialog(v_url,"","dialogWidth=420pt;dialogHeight=300pt;dialogTop=100pt;status=no;scroll=no;");
	if (!sRtn){
		return;
	}
	f.hdn_af_concern_id_list.value=sRtn;
	f.fuseaction.value="UPDATE_AF_CONCERN";
	f.submit();
	return;
}

// Ham nay duoc goi khi NSD nhan chuot vao nut "Chon" tren man hinh chon loai so lieu dua vao mau bieu do
function add_af(){
	f = document.forms(0);
	if (!checkbox_value_to_list(f.chk_af_add_id,",")){
		alert("Chưa có đối tượng nào được chọn");
	}	
	else{
		window.returnValue = checkbox_value_to_list(f.chk_af_add_id,",");
		window.close();
	}	
}
//Ham chon radio button de chap nhan hien thi cac gia tri duoc chon
function rad_accept_onclick(){
	if (document.all.rad_accept[0].checked == true){
		document.all.tr_reason.style.display = "none";
	}else{
		document.all.tr_reason.style.display = "block";
	}
}
//Ham thuc hien khi an nut cap nhat bao cao
/*function af_approve_update_onclick(fuseaction,value_status){
	f = document.forms(0);
	//replaceSource();
	//getContent();
	document.forms(0).hdn_status_af.value=value_status;
	btn_save_onclick(fuseaction);
}*/
function af_approve_update_onclick(p_fuseaction){
	if (verify(document.forms(0))){
		document.forms(0).fuseaction.value = p_fuseaction;
	} else {
		return;
	}
	btn_save_onclick(p_fuseaction);
}
//Ham lay gia tri o checkbox tu choi duyet
//  - p_checkbox_obj: ten doi tuong checkbox chi nhan 1 trong 2 gia tri 1 va 0
//  - p_checkbox_obj: ten doi tuong (kieu hidden) luu gia tri cua checkbox
function btn_checkbox_onclick(p_checkbox_obj, p_hidden_obj){
	if (p_checkbox_obj.checked){
		p_hidden_obj.value = 1;
		document.all.tr_reason.style.display = "block";
	}else{
		p_hidden_obj.value = 0;
		document.all.tr_reason.style.display = "none";
	}
}
// Di chuyen 
function move_af_concern_updown(p_concern_id, p_direction,p_fuseaction,p_hdn_obj)
{
	f = document.forms(0);
	f.fuseaction.value = p_fuseaction;
	p_hdn_obj.value = p_concern_id;
	f.hdn_direction.value = p_direction;
	f.submit();
}